//
//  SportDataModels.swift
//  TimeBoat
//
//  Created by bo wang on 2022/8/28.
//  Copyright © 2022 Time Boat. All rights reserved.
//

import UIKit
import YYModel

@objc class SportDayListUnit: NSObject, YYModel {
    @objc var calorie: Double = 0
    @objc var distance: Double = 0
    @objc var useTime: Double = 0
    @objc var year: Int = 0
    @objc var month: Int = 0
    @objc var date: String?
    
    /// 公历数据中周日是1，周一到周六是 2-7，这里需要将周日排到末尾，所以8是周日。
    lazy var weekday: Int? = {
        guard let day = ChartsDataUtil.getDateFrom(str: date) else { return nil }
        return day.weekday == .sunday ? 8 : day.weekday.rawValue
    }()
    
    lazy var day: Int? = {
        guard let day = ChartsDataUtil.getDateFrom(str: date) else { return nil }
        return day.day
    }()
}

@objc class SportTotalDataSportUnit: NSObject, YYModel {
    @objc var count: Int = 0
    @objc var sportIcon: String?
    @objc var sportName: String?
    @objc var sportType: Int = 0
    @objc var totalCalorie: Int = 0
    @objc var totalDistance: Int = 0
    @objc var totalTime: Int = 0
}

@objc class SportTotalDataModel: NSObject, YYModel {
    @objc var beginDate: String?
    @objc var dayList: [SportDayListUnit] = []
    @objc var monthList: [SportDayListUnit] = [] // 年数据接口中返回
    @objc var endDate: String?
    @objc var sportList: [SportTotalDataSportUnit] = []
    @objc var totalCalorie: Double = 0
    @objc var totalCount: Int = 0
    @objc var totalDistance: Double = 0
    @objc var totalTime: Double = 0
    
    @objc static func modelContainerPropertyGenericClass() -> [String: Any]? {[
        "sportList": SportTotalDataSportUnit.self,
        "dayList": SportDayListUnit.self,
        "monthList": SportDayListUnit.self
    ]}
}

@objc class SportDetailDataUnit: NSObject {
    // 徒步、登山、跑步、骑行
    @objc var actualDistance: Double = 0
    // 徒步、登山、篮球、羽毛球、足球、跑步机、跑步、骑行
    @objc var actualUseTime: Double = 0
    // 徒步、登山、篮球、羽毛球、足球、跑步机、跑步、骑行
    @objc var calorie: Double = 0
    // 徒步、登山、篮球、羽毛球、足球、跑步机、跑步、骑行
    @objc var date: String?
    // 徒步、登山、足球、跑步机、跑步
    @objc var totalStep: Int = 0
    // 跑步、骑行
    @objc var motionModel: Int = 0
    
    lazy var d: Date? = ChartsDataUtil.getDateFrom(str: date)
}
